{template header}

    {template title}
    <!-- box begin -->
    <div class="box">
        <!--{if $a == 'index'}-->
        <form method="post">
            <table cellpadding="1" cellspacing="1" width="100%" border="0">
                <tr>
                    <th width="8%">排序</th>
                    <th>{$this->name}名称</th>
                    <th>{$this->name}地址</th>
                    <th width="10%">新窗口</th>
                    <th width="8%">操作</th>
                </tr>
            <!--{if $result}-->
                <!--{loop $result $val}-->
                <tr>
                    <td><input type="text" name="oid[{$val['title']}]" class="span0" value="{$val['oid']}" /></td>
                    <td>{$val["title"]}</td>
                    <td>{$val['url']}</td>
                    <td>{$val['target'] ? '是' : '否'}</td>
                    <td>
                        <a title="删除{$this->name}" class="del btn btn-mini btn-danger" href="{$this->url( $c, 'del', array('id' => $val['title']) )}">删除</a>
                    </td>
                </tr>
                <!--{/loop}-->
            <!--{/if}-->
                <tr>
                    <td>
                        <a title="更新排序" class="order btn btn-small btn-info">排序</a>
                    </td>
                    <td colspan="4">
                        <a class="btn btn-success" href="{$this->url($c, 'add' )}">添加{$this->name}</a>
                    </td>
                </tr>
            </table>
        </form>
        <script type="text/javascript">
            $( ".order" ).click( function () {
                var url = "{$this->url($c)}&a=order";
                $("form" ).attr( 'action', url );
                ajaxPOST( $( this ) );
                return false;
            });
        </script>
    <!--{/if}-->
    <!--{if $a == 'add' || $a == 'edit' }-->
        <form method="post" action="{$this->url($c, 'save' )}">
            <table cellpadding="1" cellspacing="1" width="100%" border="0">
                <tr>
                    <td width="25%">{$this->name}名称：</td>
                    <td class="td2">
                        <input type="text" name="title" class="required" placeholder="请输入{$this->name}名称" value="{$a == 'edit' ? $result['title'] : ''}"/>
                        <select id="sid">
                            <option value="-1">选择分类</option>
                            <!--{loop $sort $v}-->
                            <option value="{$v['title']}">{$v['title']}</option>
                            <!--{/loop}-->
                        </select>
                        <script type="text/javascript">
                            $( "#sid" ).change( function () {
                                var v = $( this ).val();
                                if( v != -1 ){
                                    $( 'input[name="title"]' ).val( v );
                                    $( 'input[name="url"]' ).val( 'auto' );
                                }
                            });
                        </script>
                    </td>
                </tr>
                <tr>
                    <td>{$this->name}地址：</td>
                    <td class="td2">
                        <input type="text" class="required" name="url" placeholder="请输入{$this->name}地址" value="{$a == 'edit' ? $result['url'] : ''}"/>
                        (auto:系统自动生成)
                    </td>
                </tr>
                <tr>
                    <td>{$this->name}排序：</td>
                    <td class="td2">
                        <input type="text" class="span1 isint" name="oid" value="{$a == 'edit' ? $result['oid'] : '0'}"/>
                        (值越小越靠前)
                    </td>
                </tr>
                <tr>
                    <td>新窗口：</td>
                    <td class="td2">
                        <input type="checkbox" name="target" value="1"{$result['target'] ? ' checked' : ''} />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="td3">
                        <a title="保存{$this->name}" class="btn btn-success save" href="{$this->url($c)}">保 存</a>
                    </td>
                </tr>
            </table>
            </form>
        <!--{/if}-->
    </div>
    <!-- box end -->
{template footer}